﻿

using System;
using UnityEngine;

public static class NormalTool
{
    /// <summary>
    /// 获取不重复的数组
    /// </summary>
    /// <returns></returns>
    public static int[] GetRandomIntArray(int count,int min,int max)
    {
        int poolSize = max - min + 1;
        int[] pools = new int[poolSize];
        for(int i = 0; i < pools.Length; i++)
        {
            pools[i] = min + i;
        }
        for(int i = pools.Length - 1; i >= 0; i--)
        {
            int randomIndex = UnityEngine.Random.Range(0, i);
            int tmp = pools[i];
            pools[i] = pools[randomIndex];
            pools[randomIndex] = tmp;
        }
        if(count >= poolSize)
        {
            return pools;
        }
        int[] rets = new int[count];
        Array.Copy(pools,rets,rets.Length);
        return rets;
    }
}